1 /*
2 QueryJ
3
4 Copyright (C) 2002 Jose San Leandro Armend?riz
5 jsanleandro@yahoo.es
6 chousz@yahoo.com
7
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
17
18 You should have received a copy of the GNU General Public
19 License along with this library; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
22 Thanks to ACM S.L. for distributing this library under the GPL license.
23 Contact info: jsanleandro@yahoo.es
24 Postal Address: c/Playa de Lagoa, 1
25 Urb. Valdecaba?as
26 Boadilla del monte
27 28660 Madrid
28 Spain
29
30 ******************************************************************************
31 *
32 * Filename: $RCSfile: ConditionOperatorRepository.java,v $
33 *
34 * Author: Jose San Leandro Armend?riz
35 *
36 * Description: Contains references to declared operators.
37 *
38 * Last modified by: $Author: chous $ at $Date: 2003/08/29 08:14:59 $
39 *
40 * File version: $Revision: 1.1 $
41 *
42 * Project version: $Name: $
43 *
44 * $Id: ConditionOperatorRepository.java,v 1.1 2003/08/29 08:14:59 chous Exp $
45 *
46 */
47 package org.acmsl.queryj;
48
49 /*
50 * Importing ACM-SL classes.
51 */
52 import org.acmsl.queryj.ConditionOperator;
53 import org.acmsl.queryj.NestedConditionOperator;
54
55 /*
56 * Importing some JDK classes.
57 */
58 import java.lang.ref.WeakReference;
59
60 /***
61 * Contains references to declared operators.
62 * @author <a href="mailto:jsanleandro@yahoo.es">Jose San Leandro</a>
63 * @version $Revision: 1.1 $
64 */
65 public class ConditionOperatorRepository
66 {
67 /***
68 * Singleton implemented as a weak reference.
69 */
70 private static WeakReference singleton;
71
72 /***
73 * Protected constructor to avoid accidental instantiation.
74 */
75 protected ConditionOperatorRepository() {};
76
77 /***
78 * Specifies a new weak reference.
79 * @param factory the factory instance to use.
80 */
81 protected static void setReference(ConditionOperatorRepository repository)
82 {
83 singleton = new WeakReference(repository);
84 }
85
86 /***
87 * Retrieves the weak reference.
88 * @return such reference.
89 */
90 protected static WeakReference getReference()
91 {
92 return singleton;
93 }
94
95 /***
96 * Retrieves a ConditionOperatorRepository instance.
97 * @return such instance.
98 */
99 public static ConditionOperatorRepository getInstance()
100 {
101 ConditionOperatorRepository result = null;
102
103 WeakReference reference = getReference();
104
105 if (reference != null)
106 {
107 result = (ConditionOperatorRepository) reference.get();
108 }
109
110 if (result == null)
111 {
112 result = new ConditionOperatorRepository() {};
113
114 setReference(result);
115 }
116
117 return result;
118 }
119
120 /***
121 * Retrieves the equality operator.
122 * @return such operator
123 */
124 public ConditionOperator getEquals()
125 {
126 return new ConditionOperator("=") {};
127 }
128
129 /***
130 * Retrieves the unequality operator.
131 * @return such operator.
132 */
133 public ConditionOperator getNotEquals()
134 {
135 return new ConditionOperator("!=") {};
136 }
137
138 /***
139 * Retrieves the greater-than operator.
140 * @return such operator.
141 */
142 public ConditionOperator getGreaterThan()
143 {
144 return new ConditionOperator(">") {};
145 }
146
147 /***
148 * Retrieves the less-than operator.
149 * @return such operator.
150 */
151 public ConditionOperator getLessThan()
152 {
153 return new ConditionOperator("<") {};
154 }
155
156 /***
157 * Retrieves the null operator.
158 * @return such operator.
159 */
160 public ConditionOperator getIsNull()
161 {
162 return new ConditionOperator("is null") {};
163 }
164
165 /***
166 * Retrieves the belongs-to operator.
167 * @param query the query.
168 * @return such operator.
169 */
170 public ConditionOperator getBelongsTo(SelectQuery query)
171 {
172 return new NestedConditionOperator("in", query) {};
173 }
174
175 /***
176 * Retrieves the not-belongs-to operator.
177 * @param query the query.
178 * @return such operator.
179 */
180 public ConditionOperator getNotBelongsTo(SelectQuery query)
181 {
182 return new NestedConditionOperator("not in", query) {};
183 }
184 }
This page was automatically generated by Maven